package com.ye.zcswzlms.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

import java.io.Serializable;

@Data
@NoArgsConstructor
@Component
public class CommonResult<T> implements Serializable {
    private int code;
    private String msg;
    private T data;

    public CommonResult(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public CommonResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static <T> CommonResult<T> getSuccess(T data){

        return new CommonResult(200,"成功",data);
    }
    public static CommonResult getSuccess(){
        return new CommonResult(200,"成功",null);
    }

    public static CommonResult getFail(String msg){
        return new CommonResult(-9999,msg);
    }
}
